<?xml version="1.0"?>
<Denemo>
  <merge>
    <title>A Denemo Keymap</title>
    <author>AT, JRR, RTS</author>
    <map>
      <row>
        <after>BookCopyright</after>
        <action>IncipitFromSelection</action>
        <scheme>;;;IncipitFromSelection
(let ((lily ""))
  (define (accum)
    (let ((this (d-GetLilyPond)))
      (if this
	(set! lily (string-append lily this)))))
;;if no selection select the first two measures of the top staff of the first movement
  (if (not (d-GoToSelectionStart))
      (begin
	(while (d-PreviousMovement))
	(while (d-MoveToStaffUp))
	(d-MoveToBeginning)
	(d-SetMark)
	(d-MeasureRight)
	(RepeatProcWhileTest d-CursorRight (lambda () (not (Appending?))))))

  (SingleAndSelectionSwitcher accum)
  (set! lily (string-append (d-GetPrevailingClefAsLilyPond) " "  (d-GetPrevailingTimesigAsLilyPond) " "  (d-GetPrevailingKeysigAsLilyPond) " " lily))
  (set! lily (string-append "\n\\markup \\score {\n{" lily "\n}\n\\layout {indent = 0.0\\cm }\n}"))

  (SetScoreHeaderField "incipit" lily #f))
  
</scheme>
        <label>Incipit from Selection</label>
        <tooltip>Creates an incipit from the selection. This music will be printed on the title page. Only one voice is supported.</tooltip>
      </row>
    </map>
  </merge>
</Denemo>
